package xmlService;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import beans.FinanciacionBean;
import beans.ListaDePreciosBean;
import beans.PagoContadoBean;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;


public class ListaDePreciosXmlService {

	public static void main(String[] args) {
		ListaDePreciosBean sc = cargarListaDePrecios();
	}

	public static ListaDePreciosBean cargarListaDePrecios()
	{
		try {
			FileInputStream fis = new FileInputStream("src/XML/ListaPrecio.xml");
			return cargarListaDePrecios(fis);
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;				
	}
	
	public static ListaDePreciosBean cargarListaDePrecios(InputStream is)
	{
		ListaDePreciosBean c = null;
		
		XStream xstream = new XStream( new DomDriver());
		xstream.autodetectAnnotations(true);  
		
		xstream.alias("ListaPrecios", ListaDePreciosBean.class);
		xstream.alias("PagoContado", PagoContadoBean.class);
		xstream.alias("Financiacion", FinanciacionBean.class);
		FileInputStream fis;
			c = (ListaDePreciosBean) xstream.fromXML(is);
		
		return c;				
	}
	
}
